import request from '@/request'

export function getAllTags() {
  return request({
    url: '/tags',
    method: 'get',
  })
}

export function getAllTagsDetail() {
  return request({
    url: '/tags',
    method: 'get',
  })
}

export function getHotTags() {
  return request({
    url: '/tags/hot',
    method: 'get',
  })
}

export function getTag(id) {
  return request({
    url: `/tags/${id}`,
    method: 'get',
  })
}

export function getTagDetail(id) {
  return request({
    url: `/tags/detail/${id}`,
    method: 'get',
  })
}

export function getTagForAdmin(token, page, formData) {
  return request({
    headers: {'Authorization': token},
    url: `/tags/admin/all`,
    method: 'post',
    data:{
      page: page.pageNumber,
      pageSize: page.pageSize,
      tagName: formData.tagName
    }
  })
}

export function changeTag(token, formData){
  return request({
    headers: {'Authorization': token},
    url: 'tags/admin/change',
    method: 'post',
    data:{
      id: formData.id,
      tagName: formData.tagName,
      avatar: formData.image
    }
  })
  
}

export function addTag(token, formData){
  return request({
    headers: {'Authorization': token},
    url: 'tags/admin/add',
    method: 'post',
    data:{
      tagName: formData.tagName,
      avatar: formData.image
    }
  })
  
}

export function deleteTag(token, id){
  return request({
    headers: {'Authorization': token},
    url: `tags/admin/delete/${id}`,
    method: 'post'
  })
  
}

// export function deleteTagList(arr){
//   return request({
//     url: `tags/deleteList`,
//     method: 'post',
//     data:{
//       arr:arr
//     }
//   })
  
// }

export function deleteTagList(token, arr){
  return request({
    headers: {'Authorization': token},
    url: `tags/admin/deleteList?arr=` + arr,
    method: 'get',
    
  })
  
}


